In [1]:
%cd ~/twitter-bots-smw-2016/


/Users/nickmacri/twitter-bots-smw-2016

In [2]:
from library import TwitterBot

An MVP Twitter bot that anyone can use


In [4]:
bot1 = TwitterBot('test1')
bot2 = TwitterBot('test2')
bot3 = TwitterBot('test3')

kanye = TwitterBot('production')

In [19]:
# 
kanye.tweet('Attendees will learn to like small dogs and cigarettes')


Out[19]:
<twitter.status.Status at 0x110ade950>

In [5]:
# they can talk between the two of them
tweet = bot3.tweet("Testing 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11...")
reply_tweet = bot1.tweet("I can hear you!", in_reply_to=tweet)

In [7]:
# they remember their conversations
bot1.should_reply(tweet)


Out[7]:
False

In [8]:
bot3.should_reply(reply_tweet)


Out[8]:
False

In [9]:
# or they can have a conversation 
tweet = bot1.tweet("Is there anybody out there?")
reply_tweet1 = bot2.tweet("Mr. Watson--come here--I want to see you.", in_reply_to=tweet)
reply_tweet2 = bot3.tweet("wait, I thought I was your one and only. who is @%s?" % bot1.user.screen_name, 
                          in_reply_to=reply_tweet1)

In [10]:
# they should all be friends
bot1._api_client.CreateFriendship(user_id=bot3.user.id)
bot1._api_client.CreateFriendship(user_id=bot2.user.id)
bot2._api_client.CreateFriendship(user_id=bot3.user.id)
bot2._api_client.CreateFriendship(user_id=bot1.user.id)
bot3._api_client.CreateFriendship(user_id=bot2.user.id)
bot3._api_client.CreateFriendship(user_id=bot1.user.id)


Out[10]:
<twitter.user.User at 0x11000cbd0>

In [11]:
# and they should all like eachother's posts, why not?
bot1._api_client.CreateFavorite(status=reply_tweet1)
bot1._api_client.CreateFavorite(status=reply_tweet2)

bot2._api_client.CreateFavorite(status=tweet)
bot2._api_client.CreateFavorite(status=reply_tweet2)
# except maybe bot 3 he seems a bit wary of bot 1


Out[11]:
<twitter.status.Status at 0x11000cd50>